/*
 * @: 如何链式调用中间件
 * @Version: 1.0
 * @Autor: ziwei
 * @Date: 2021-11-01 15:26:11
 * @LastEditors: ziwei
 * @LastEditTime: 2021-11-01 15:50:46
 */
let store = {getState,dispatch}
function promise(store){
  return function (next) {
    return function (action) {
      next(action);
    }
  }
}

function thunk(store){
  return function (next) {
    return function (action) {
      next(action);
    }
  }
}

function logger(store){
  return function (next) {
    return function (action) {
      next(action);
    }
  }
}

let middlewares = [promise,thunk,logger]
let chain = middlewares.map(middlewares=>middlewares(store));

function compose(...funcs) {
  if(funcs.length ==0 ){
    return (args)=>args
  }
  else if(funcs.length==1){
    return funcs[0]
  }
  return funcs.reduce((a,b)=>(...args)=>a(b(args)))
}